<template>
	<u-mask :show="showPopup" @click="closePopup">

		<view class="popup-warp" v-if="vip==true">
			<view class="popup-box" @tap.stop>

				<block v-if="lang=='ru'">
					<u-button @click="buyScore()" :custom-style="customStyle1" hover-class="none" class="vip-button">
						购买积分
					</u-button>
				</block>
				<block v-if="lang=='zh'&&score==true">
					<u-button @click="buyScore()" :custom-style="customStyle1" hover-class="none" class="vip-button">
						购买积分
					</u-button>
				</block>

				<u-button @click="buyVip()" :custom-style="customStyle2" class="vip-button" hover-class="none">
					立即开通
				</u-button>
			</view>
		</view>
		<view class="popup-warp" v-if="vip==false">
			<image :src="HTTP_IMG_UTL+'/quanxian.png'" style="border-radius: 0px;width: 80%; margin-left: 0%;"></image>
		</view>

	</u-mask>
</template>
<script>
	import {
		IMAGE_URL,
		HTTP_IMG_UTL
	} from '@/config/app';
	export default {

		props: {
			show: {
				type: Boolean,
				default: false,
				required: true,
			}
		},
		data() {
			return {
				HTTP_IMG_UTL,
				lang: getApp().globalData.lang,
				vip: false,
				showPopup: false,
				score: false,
				customStyle1: {
					color: '#964447',
					borderColor: '#964447',
					width: '240rpx',
					height: '60rpx',
					background: '#ffffff',
					borderRadius: '26rpx',
				},
				customStyle2: {
					color: '#ffffff',
					width: '240rpx',
					height: '60rpx',
					background: 'linear-gradient(110deg, #DD2910 0%, #F79B29 100%)',
					borderRadius: '26rpx',
				},
			};
		},
		mounted() {
			this.showPopup = this.show

			this.$u.api.user.appCheck().then(res => {
				this.report = res.report
				this.score = res.score
				this.vip = res.vip
			})
		},
		methods: {
			closePopup() {
				this.$emit('handeleVip')
				let pages = getCurrentPages();
				let currentPage = pages[pages.length - 1];
				currentPage.vipShow = false
				currentPage.$vm.vipShow=false;
			},
			buyVip() {
				this.$u.route('pages/user/MemberCenter/MemberCenter')
			},
			buyScore() {
				this.$u.route('pages/user/my-integral/BuyPoints')
			},
		}
	}
</script>

<style lang="scss" scoped>
	.popup-warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.popup-box {
		width: 100%;
		height: 840rpx;
		background-image: url("https://gluz-oss.oss-cn-beijing.aliyuncs.com/uploads/20231117/607a1bb148720469d75f78ee0769a14c.png");
		background-repeat: no-repeat;
		background-size: cover;
		//background-size:100% 100%;
		background-position: center center;
		background-clip: content-box;
		background-origin: border-box;
		display: flex;
		justify-content: center;
	}

	.vip-button {
		margin-top: 85%;
	}
</style>